﻿@model PagedList<Common.Background.WebManageMenus>
@{
    ViewBag.Title = "Index";
}
@Html.Partial("ContentListTag.Partial", new List<Common.Background.Models.LinkModel> {
    new Common.Background.Models.LinkModel("菜单列表列表展示","/Menu/Index?flag=0"),
    new Common.Background.Models.LinkModel("菜单列表树型展示","/Menu/Index?flag=1"),
    })

@if (string.IsNullOrEmpty(Request.QueryString["flag"]) || Request.QueryString["flag"] == "0")
{
    <table>
        <tr>
            <th width="100"></th>
            <th>编号
            </th>
            <th>菜单名称
            </th>
            <th>上级菜单
            </th>
            <th>级别
            </th>
            <th>URL
            </th>
            <th>状态
            </th>
            <th>相关角色
            </th>
        </tr>
        <tbody>
            @if (Model != null && Model.Count() > 0)
            {
                foreach (var item in Model)
                {
                <tr>
                    <td>
                        @Html.ActionLink("编辑", "Edit", new { id = item.MenuID }) |
                        @Html.ActionLink("删除", "Delete", new { id = item.MenuID })
                    </td>
                    <td>
                        @item.MenuID
                    </td>
                    <td>
                        @item.MenuName
                    </td>
                    <td>
                        @item.ParentID
                    </td>
                    <td>
                        @item.MenuLevel
                    </td>
                    <td>
                        @item.LinkUrl
                    </td>
                    <td>
                        @(((EntityFrameworks.Entity.Core.CommonEnums.Status)item.Status).GetDescription())
                    </td>
                    <td>
                        @foreach (var role in item.WebManageRoles)
                        { 
                            <div>@role.RoleName</div>
                        }
                    </td>
                </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="8">没有相关信息
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="7">@EntityFrameworks.Web.Core.Helper.PagerHelper.Pager(Html, Model)
                </td>
            </tr>
        </tfoot>
    </table>
}
else
{
    @Html.GetDataTree(new BackgroundBase<WebManageMenus>().GetModel(), "MenuID", -1, "Menu")
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#MenuID_Tree").jstree({
            "plugins": ["themes", "html_data", "ui"],
            "core": { "initially_open": ["MenuID_node1", "MenuID_node2"] } //初始化时打开树的节点
        })

    });
</script>
